System and method for providing language-specific extensions to the compare facility in an edit system

ABSTRACT

An extension of any n-file compare and/or merge utility in an edit system includes services provided by a parser attached to the edit system for the particular file type. A compare command in the edit system is enabled by an extension-registration process to query, upon activation, for any compare extensions supported by the parser. Selected files are displayed to a user with non-comparing elements highlighted according to a compare strategy selected with reference to the compare extensions.

BACKGROUND OF THE INVENTION

[0001] 1. Technical Field of the Invention

[0002] This invention pertains to editing systems. More particularly, itrelates to language-specific extensions to the compare facility in anediting system.

[0003] 2. Background Art

[0004] Regular file compare, carried out by a straightforward comparisonof the text elements of a number of files, is not adequate for logical,effective comparison of source files in a manner that will improve theproductivity of programmers and assist them during their various codedevelopment and code maintenance tasks.

[0005] In addition to the options normally provided by comparefacilities (e.g., ignore blanks, ignore case), there is a need in theart for a system and method providing language specific requirements.

[0006] It is, therefore, an object of the invention to provide a systemand method for comparing source files code while ignoring the comments.

[0007] It is a further object of the invention to provide a system andmethod for comparing functions and/or methods defined in source files(names, arguments, etc.), regardless of their detailed implementation.

[0008] It is a further object of the invention to provide a system andmethod for comparing code while ignoring the text located outsidemargins, in a prefix area, and/or including or excluding sequencenumbers, and so forth.

[0009] It is a further object of the invention to provide a system andmethod for comparing source code statement-by-statement, e.g., one-linestatement vs. a reformatted statement spread over a number of documentlines, effectively ignoring the differences in formatting styles betweenprogrammers or coding standards and practices between projects orinstitutions.

[0010] It is a further object of the invention to provide a system andmethod for comparing constant definitions or keys in, for example, Javaresource files, where the values are different (e.g., new constantvalues or NLS-translated values), in which case the user may still beinterested in an indication that the value changed, but does not want tohave every line flagged as non-comparing.

[0011] It is a further object of the invention to provide a system andmethod for comparing documents with expected (controlled) differences,such as the change of a class name or a variable name.

[0012] It is a further object of the invention to provide a system andmethod facilitating language-sensitive application of compare options(e.g., ignore case and ignore blanks applied only to language elementsand comments, but not to contents of strings).

[0013] It is a further object of the invention to provide a system andmethod for comparing documents in any manner that is advantageous for aspecific type of filed handled by the edit system.

SUMMARY OF THE INVENTION

[0014] In accordance with the invention, a system and method for theextension of any n-file compare and/or merge utility in an edit systemincludes services provided by a parser attached to the edit system forthe particular file type. A compare command in the edit system isenabled by an extension-registration process to query, upon activation,for any compare extensions supported by the parser.

[0015] In accordance with an aspect of the invention, there is provideda computer program product configured to be operable to extend anyn-file compare and/or merge utility in an edit system by providingservices particular to a specific file type within a parser attached tothe edit system for that particular file type.

[0016] Other features and advantages of this invention will becomeapparent from the following detailed description of the presentlypreferred embodiment of the invention, taken in conjunction with theaccompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

[0017]FIG. 1 illustrates a typical pull-down menu for the comparefunction in an edit system.

[0018]FIG. 2 illustrates the main components of an edit system inaccordance with the preferred embodiment of the invention.

[0019] FIGS. 3-6 are flow diagrams illustrating the steps of thepreferred embodiment of the invention for invoking a compare utility.

[0020]FIG. 7 illustrates an aspect of the registration of compareextensions.

[0021]FIG. 8 illustrates a pull-down menu for the compare function in anedit system including, for example, two extended compare options.

[0022]FIG. 9 illustrates components of an edit system implementing thetwo extended compare options of FIG. 8.

[0023]FIG. 10 is a screen capture illustration of a regular compare oftwo C-language documents.

[0024]FIG. 11 is a screen capture illustration of a compare of the twoC-language documents of FIG. 10 according to the present invention.

BEST MODE FOR CARRYING OUT THE INVENTION

[0025] In accordance with the preferred embodiment of the invention, thecompare command in an edit system is enabled by anextension-registration process to query, upon activation, for anycompare extensions supported by the parser attached to the edit systemfor the currently active files participating in the compare. This allowsthe parser to add its own compare options, specific to the file type ithandles.

[0026] In this manner, the compare utility is able to smartly handledifferences in content based on the internal structure of the documents,as this is recognized by the parser. Furthermore, the compare utilitycan in this manner be customized based on the individual parsersabilities, but still in a consistent manner within the edit system.

[0027] When these extension options are selected by a user, the parseris invoked to provide one or more specific methods extending those usedby the compare utility, such as supplying the (modified) content of thedocument text (for example, with the comments stripped out, orreformatted to include an entire language statement).

[0028] Compare Utility Options

[0029] Referring to FIG. 1, a typical pull-down menu 100 for the comparefunction 102 in an edit system is illustrated.

[0030] Menu items 104-108 and 118-122 represent compare utility actionswhich work in the same manner regardless of the language context of thedocuments being compared.

[0031] Refresh 104 refreshes compare after any of the compared documentshas been modified. This action 104 redoes the latest compare operation,with the same settings, options, and on the same documents, after thecontents of any one or more of these documents has been modified.

[0032] Next mismatch 106 results in advancing the cursor to the nextmismatch.

[0033] Previous mismatch 108 positions the cursor onto the previousmismatch.

[0034] Protect view 118 protects the view from editing. If theparticular implementation of the compare utility displays n viewsside-by-side of the documents being compared, this menu action 118applies to the currently-active view (the one with the focus). If thecompare utility shows a composite view of the main document compared toa file or files, then this action prevents the main document from beingedited.

[0035] Show mismatches only 120 results in displaying only themismatches.

[0036] Exit compare 122 exits the compare utility/mode. If the compareutility displays n views side-by-side of the documents being compared,these views are terminated and disposed. If the compare utility shows acomposite view of the main document and the differences to the otherdocuments, then all parser classes, highlights, and othercompare-related pertinent information are cleared in this main documentview.

[0037] Menu items 110-116 are compare options (or equivalently, settingsin a Preferences dialog) which may be affected by the type of thecompared documents, or that language-specific compare extensions mayhave to alter. These options 110-116 form part of the compare strategy.

[0038] Selection of ignore leading blanks 110 results in leadingblanks/white space being removed from text during the comparison.

[0039] Ignore trailing blanks 112 results in trailing blanks beingremoved from text during the comparison.

[0040] Ignore all blanks 114 results in all blanks being removed fromtext during the comparison.

[0041] Ignore case 116 results in text being folded to lower/upper caseduring the comparison.

[0042] In accordance with an embodiment of the invention, the parser isable to override any of these compare options 110-116. For example, forignore all blanks 114, blanks that form part of a C/C++/Java languagestring should not be ignored: “ABC” is very different from “A B C”. Inaccordance with this aspect of the invention, such new compare optionsare also added by the parsers.

Edit System

[0043] Referring to FIG. 2, the main components of a typical edit system140 are illustrated, and will be described with particular reference toan embodiment of the system of the invention. Each block shown in editsystem 140 represents one or more classes and comprise functionsperformed by the code in edit system 140, as well as data structuresmaintained for the documents being edited.

[0044] Document class 144 manages one document in the edit system:either a file loaded in the edit system, or a newly-created document.One or more documents 144 may be opened in an edit system session.

[0045] View class 146 manages a document view in the edit system 140.There may be several views on the same document open simultaneously inthe edit system.

[0046] Screen class 148 handles the screen, i.e., the display of theedit window. It manages the display attributes of the rendered elementsas set up in view 146 by the edit system and its attachedtools—tokenization and colorization of the text as set up by the parsersand other utilities (e.g., the differences marked up by the compareutility in the edit system), the text selection in effect, etc. There isone instance of this class 148 for every document View 146.

[0047] Element class 150 manages each text line of document 144. Itcontains the text of the corresponding line in the document. Inaddition, show elements may be set in the edit system, which are linesof text displayed in the view of the document but which do not form partof it, and consequently are not saved when the document being edited issaved (e.g., imbedded error messages set up by a build utility, ordifferences shown by the compare utility). A linked list of elements 150is maintained for each document 144 in edit system 140.

[0048] ElementView class 152 manages the view for one element 150. Foreach view 146 opened on document 144, and ElementView class 152corresponding to each element 150 is instantiated. It keeps track of theparser classes and token styles assigned by the language parser(s) andother associated utilities in the view 146, and also contains formattingflags and display attributes.

[0049] Parameter class 154 manages a setting of the edit system 140, andprovides means for querying and setting of its install, default, andcurrent values, according to its defined scope in the edit system. Allthe edit system settings are managed by classes extending parameter 154for the handling of a particular setting.

[0050] Action class 156 manages one named action in the edit system.

[0051] Command class 158 manages one named command and its arguments.

[0052] Compare class 160 in edit system 140 handles the compare commanditself and its arguments, and manages the registration and activation ofcompare extensions 168.

[0053] CompareStrategy class 162 provides a set of functions used for acompare operation. A linked list of CompareStrategies is maintained foreach active compare session 160.

[0054] CommonParser class 164, from which the language parsers derive,implements a set of generic parser services and provides a parserinterface to the edit system 140.

[0055] Parser class 166 is an edit-system extension which providesdocument-specific editing functionality.

[0056] Compare extension 168 provides document-specific extensions tothe Compare utility.

[0057] Activities in edit system 140 are triggered by actions andcommands. The edit system has a set of built-in (predefined) actions andcommands. The system can be customized with user-defined actions andcommands, which are new or override built-in (default) actions orcommands. Actions can be associated with keys and menus (pull-down,toolbar, pop-up). For example, the “open” action, associated with thekey combination “Ctrl+O” and the “Open . . . ” item on the “File”pull-down menu, brings up the Open dialog, allowing the user to choose afile to be opened as a document 144 in edit system 140.

Language Parsers

[0058] In accordance with the preferred embodiment of the invention,compare utility 160 is extendible through parser interfaces 165.

[0059] A language-specific parser 166 is an extension to the edit system140 which provides a variety of functions which assist users of editsystem 140 with their editing tasks. A typical language parser 166 in anedit system 140 reads and analyzes (parses) document 144 contentsaccording to its type; maintains this document information up-to-datethroughout its editing; provides token colorization; provides acontent-outline of the document; provides code-assist functions;provides automatic formatting of the user input (such ascursor-positioning and text-positioning indentation); providesnavigation between classes and tokens, i.e., smart navigation betweenstructural elements of document 144 as identified in a particular view146 on the document; and provides language-sensitive help on thecontents of the document.

[0060] Language-specific parsers 166 are attached to the edit system 140via a file-type association mechanism. For example, the JavaParser class166 is loaded when a Java source file (*.java or *.jav) is opened in theedit system. A parser 166 first gets control after a file has beenloaded in the edit system (to perform an initial total parse), andsubsequently it is called following certain edit system events, such aschanges made to the document (incremental parse).

[0061] Parser 166 analyzes the document, and marks structural elementsin it at various degrees of detail. Parser classes are defined for aview 146, that broadly classify element types in the view. Each element150 can belong to one or more parser classes. For example, text elements150 which contain comments are marked with parser class CLASS_COMMENT,C-language function header elements with CLASS_FUNCTION, Java-languagemethod signature elements with CLASS_METHOD, etc. Additional classes maybe defined by a parser to link consecutive elements that belong to thesame language construct (CLASS_FORWARDLINK, CLASS_BACKWARDLINK), toindicate if a text element is empty (CLASS_SPACE), and so on.

[0062] More detailed information is recorded by parser 166 via tokenstyles set in the element view 152 for a text element 150. The tokenstyle characters identify all the text characters in an element 150, andpermit association of the text with display attributes (e.g., anitalicized, green-color display and print font style for the commentcharacters in the element, i.e., those text characters assigned thecomment token style).

[0063] The set of parsing functions described above is usuallyimplemented on top of any available grammar-parser utility, adapted foruse in an edit system and further expanded to support these functions.

[0064] The parser-set information is used by the edit system 140 todisplay the document 144 in a view 146 (colorized, filtered sections ofthe source, a bounded segment of the source, etc.), by other utilitiesand tools attached to the edit system to get detailed information aboutthe structure of the document 144 for carrying out context-sensitiveactions, and by the parser 166 itself as reference points forincremental parsing and for its other language-specific operations.

Compare Process

[0065] Table 1 represents how the compare process in a typical compareutility 160 works. Lines 1-9 indicate the typical settings and functionswhich may be modified by compare extensions 168. This set of functionsis, according to the present invention, defined as a compare strategy.Alternative embodiments of the invention may include additional or othersuch settings and functions than those indicated here. Compareextensions 168 will modify one or more of these settings and functionsin a compare strategy, and consequently modify the compare process for aparticular compare operation. TABLE 1 COMPARE PROCESS for each documentview participating in compare // build vector of hash values forelements' text for all text elements in document view text :=elementText(element)    1 if ignoreCase      2 text := lowerCase(text)   3 if ignoreLeading Blanks     4 text := stripLeadingBlanks(text)   5if ignoreTrailingBlanks    6 text := stripTrailingBlanks(text)   7 ifignoreAllBlanks     8 text := stripAllBlanks(text)    9hashValues[element number] := hash(text) elements[element number] :=element compare the hash-values vectors, determine largest blocks thatcompare, mark elements in the document view(s) accordingly, set upcompare bars to visually summarize differences and link comparingblocks.

[0066] Referring to Table 2, the compare process, as implemented incompare utility 160 according to this invention, will be the same forall compare strategies 162. TABLE 2 COMPARE PROCESS FOR ALL COMPARESTRATEGIES for each document view participating in compare // buildvector of hash values for elements' text strategy := instance ofselected compare strategy for view for all text elements in documentview text := strategy.elementText(element)   1 if strategy.ignoreCase()    2 text := strategy.ignoreCase(text)   3 ifstrategy.ignoreLeadingBlanks()    4 text :=strategy.ignoreLeadingBlanks(text)  5 if strategy.ignoreTrailingBlanks()  6 text := strategy.ignoreTrailingBlanks(text) 7 ifstrategy.ignoreAllBlanks()    8 text := strategy.ignoreAllBlanks(text)  9 hashValues[element number] := hash(text) elements[element number] :=element compare the hash-values vectors, determine largest blocks thatcompare, mark elements in the document view(s) accordingly, set upcompare bars to visually summarize differences and link comparingblocks.

Invocation of the Compare Utility

[0067] Referring to FIGS. 3-6, when in step 170 the default “compare”action 160 is invoked in the edit system 140, in step 172 a comparedialog is displayed, which allows the user in step 174 to select thecompare entities; for example, the existing document views 146 tocompare or, depending on the edit system implementation, to select thefile(s) with which to compare the currently active document view 146,for which file( ) document view(s) are instantiated in step 176.

[0068] Once the selected compare views 146 are determined (andoptionally created for the selected file(s) not currently opened in theedit system), compare utility 160 can in step 178 establish whether theattached parsers 164 and 166 are identical, and consequently is able instep 180 to initiate the compare-extension 168 registration process.Depending on the desired embodiment, in step 180 the compare-extension168 registration may now be invoked, and in step 182 the user ispresented another dialog with the new compare options registered toselect the desired option. Alternatively, the compare can proceed instep 190 with the default compare action in accordance with the defaultoptions in effect; subsequently, the user can in step 192 select thecompare menu pull-down, whose creation in step 194 will trigger in steps178 and 180 the registration process, and in steps 182 and 196 thecompare menu will be populated with the additional compare optionsregistered for execution in steps 184 and 188.

[0069] Referring to FIG. 6, other “compare” actions 200 can be definedprogrammatically in the edit system 140, which will invoke in steps 202and 204 the compare utility 160 directly with a certaincompare-extension strategy.

Registration of Compare Extensions

[0070] Referring to FIG. 7, compare utility 160 calls the parser 166 toregister any compare-extensions 168 whenever all the documents 144participating in the compare/merge have the same parser 166. Similarly,this is done for extensions 168 registered by parsers extending the samebase parser 166. For example, parsers 212-224 for various flavors of theC language for different platforms (such as Windows, AIX, and OS2), allextend a base C-language parser 210. As a consequence, documents 144handled by any combination of these parsers 212-224 can participate inthe compare extensions 168 registered by the basic CParser 210.

[0071] The registration process is initiated by the Compare utility 160calling a CommonParser 164 entry point registerCompareExtensions( ) toallow the parser for the document view 146 to register its comparestrategies 162, if any, such as a parser default strategy and/oradditional strategies for extra compare options. This is accomplished bythe parser 166, which extends CommonParser 164 and overridesregisterCompareExtensions( ) if it has any compare extensions 168 toregister, to call in turn the Compare utility 160 entry pointregisterstrategy( ) for each compare extension 168 it wants to register.

[0072] The Compare class 160 adds each compare strategy 162 indicatedvia the registerStrategy( ) calls to its linked list of strategies forthe current compare session. When it is returned control fromregisterCompareExtensions( ), it is able to go through thecompareStrategiesList just created, and query each registered strategyfor the compare option to display to the user, and create an edit-systemaction for each such option (e.g., menu item, checkbox, etc.).

[0073] When the user selects a particular compare option, the definedaction is run, which in turn calls the compare process 160 with theassociated compare strategy 162.

Compare Strategy

[0074] Each compare extension 168 implements a compare strategy, i.e.,implements the compare-utility callback extendible methods, which eitheroverride, or extend compare-utility 160 methods, or call super( ) (theparent-class method) to effectively change nothing in the Compareutility default strategy (when the method is not altered by theparticular compare extension 168).

[0075] Through this method-extension mechanism, various other comparedetails may be implicitly modified as pertinent to the option selected(e.g., turning on by default the “ignore blanks” setting, so as toignore any blanks outside the language constructs when ignoring commentsin the comparison).

[0076] Table 3 illustrates a typical base CompareStrategy class asimplemented in the compare utility 160 of edit system 140. It definesthe default compare strategy 162 for the basic compare options definedin the edit system. TABLE 3 COMPARE CompareStrategy ------------------------------ /** * This class consists of methods for acompare-command action. * The implementation of this class provides thedefault strategy * for a compare action. * Parsers may extend this classto override or extend methods, * in order to create their defaultstrategy, or a compare strategy * for a language-specific compareextension. */ public class CompareStrategy { // keep a reference to thecompare view using this strategy protected View _view; * Constructor forthis compare strategy. * It instantiates the strategy for a particularcompare view. */ public CompareStrategy(View view) { _view = view; }/** * Retrieve the compare view of this strategy instance. */ publicView view() { return_view; } /** * Retrieve the name of the compareoption implemented through this * strategy. * The implementation of thismethod in the default compare strategy * does nothing, except returnnull. The parser implementing a * particular strategy for a compareoption should override this * method to return a string suitable fordisplay as a compare-option * menu item. */ public StringcompareOptionName() { return null; } /** * Query whether differences inthe character case of the compared * text are significant. * Theimplementation of this method in the default compare strategy * returnsthe currently effective setting of the “compare.ignoreCase” *edit-system parameter for this compare view. */ public booleanignoreCase() { return Compare.ignoreCaseParameter().currentValue(_view);} /** * Return a case-neutral variation of the text passed in. * Theimplementation of this method in the default compare strategy * returnsthe lower-case version of the entire submitted string. */ public StringignoreCase(String text) { return lowerCase(text); } /** * Query whetherthe compare operation should ignore leading * blanks in the comparedtext. * The implementation of this method in the default comparestrategy * returns the current setting of the“compare.ignoreLeadingBlanks” * edit-system parameter for this compareview. * */ public boolean ignoreLeadingBlanks() { returnCompare.ignoreLeadingBlanksParameter().currentValue (_view); } /** *Return a no-leading-blanks variation of the text passed in. * Theimplementation of this method in the default compare strategy * returnsthe submitted text with any leading white space stripped. */ publicString ignoreLeadingBlanks(String text) { returnstripLeadingBlanks(text); } /** * Query whether the compare operationshould ignore trailing blanks * in the compared text. * Theimplementation of this method in the default compare strategy * returnsthe current setting of the “compare.ignoreTrailingBlanks” * edit-systemparameter for this compare view. */ public booleanignoreTrailingBlanks() { returnCompare.ignoreTrailingBlanksParameter().currentValue (_view); } /** *Return a no-trailing-blanks variation of the text passed in. * Theimplementation of this method in the default compare strategy * returnsthe submitted text with any trailing white space stripped. */ publicString ignoreTrailingBianks(String text) { returnstripTrailingBlanks(text); } /** * Query whether the compare operationshould ignore blank * characters (white space) in the compared text. *The implementation of this method in the default compare strategy *returns the current setting of the “compare.ignoreAllBlanks” *edit-system parameter for this compare view. * */ public booleanignoreAllBlanks() { returnCompare.ignoreAllBlanksParameter().currentValue(_view); } /** * Return ano-blanks variation of the text passed in. * The implementation of thismethod in the default compare strategy * returns the submitted text withany white space stripped. */ public String ignoreAllBlanks(String text){ return stripAllBlanks(text); } /** * Retrieve the text of an elementin the document, which will be used * in the compare process. * Theparser implementing a particular compare strategy may * override thismethod to return an altered string of the actual text * element content(e.g., with the comments stripped for an “Ignore * comments” compareoption). */ public String elementText(int element) { // retrieve elementElement e = view.elementAt(element); // valid element - return its textif (e != null) { return e.text(); } // element not available - returnnull else { return null; } } }

Compare Extension

[0077] Compare utility 160 loads and invokes the particular parser classwhen the user selects an extension option. The compare utility then runsin the usual manner, however certain of its methods are now handled bythe parser 166 for the particular type of document and compare option.

[0078] Compare strategies can be implemented either in the parser 166itself, or in the common parser 164 for more generic compare options(such as “Ignore comments”), with the language-specific methods furtherimplemented in the language parsers 166.

[0079] Referring to FIG. 8, there are two extensions 132, 134 providedto the edit system compare utility for C documents. The C languageparser 166, in conjunction with the Common Parser 164, effectivelyimplements both these CompareStrategy extensions, overriding orextending one or more methods in the default CompareStrategy class, forthe compare options “Ignore comments” 132 and “Compare functions only”134. FIG. 8 illustrates the modified Compare menu pull-down of FIG. 1after the addition of these two extensions 168.

[0080] The two additional compare options 132,134 are added to thecompare menu 130 during the compare-extension registration process.

[0081] Referring to FIG. 9, a preferred implementation of the editsystem of these two compare extensions 132, 134 is illustrated. In thisexample, common parser 230 corresponds to common parser 164, andincludes the compare strategy 162 for option “Ignore comments”CompareStrategylgnoreComments 232, and procedure elementsTextNoComments() 234. C parser 210 corresponds to parser 166, and includes procedureelementTextNoComments( ) 236 which overrides procedureelementTextNoComments( ) 234 in the common parser 230, procedureelementCode( ) 238, and compare strategy 162 for option “Comparefunctions only” CompareStrategyFunctions 240.

[0082] The methods not implemented in the extension strategy classesbelow will activate, when invoked during the comparison, the originalmethods in the base CompareStrategy class (the default compare strategy162 is illustrated in Table 3): TABLE 4 COMPARE EXTENSION COMMON PARSER:CompareStrategyIgnoreComments ---------------------------------------------------------- /** * This compare strategy consists ofmethods for the compare- * command “Ignore comments” action. It extendsthe default * Compare strategy. Only methods that are different fromthe * default CompareStrategy are implemented in here. * * This compareextension is registered with Compare for all parsers * that supportstripping of comments from the element text. */ public classCompareStrategyIgnoreComments extends CompareStrategy { /** * Invoke theconstructor of the default compare strategy. */ publicCompareStrategyIgnoreComments(View view) { super(view); } * Return thename of the compare option implemented through this * strategy. */public String compareOptionName() { return “Ignore comments”; } *Indicate that the compare operation should ignore blank characters *(white space) in the compared text. * Once comments are stripped fromthe element text, it's important * to ignore the left-over blankcharacters, regardless of the manner * in which the parser removes thecomments. */ public boolean ignoreAllBlanks() { return true; } /** *Retrieve the text of an element in the document, which will be used * inthe compare process. All the comments are stripped. */ public StringelementText(int element) { // invoke the call-back (hook) which theparser extends in // order to carry out the actual comment-removalreturn elementTextNoComments(element); } }elementTextNoComments(element) ------------------------------ /** * Thismethod is part of the Common Parser interface. * A parser may overridethis method to return the text of an element * with the commentsstripped out. * * The implementation of this method in the Common Parserreturns * the complete text (‘as is’) of the element. * @param element -element in the document */ String elementTextNoComments(int element) {return view.elementText(element); } C PARSER: CompareStrategyFunctions------------------------ ------------------------ /** * This comparestrategy consists of methods for the compare- * command “Comparefunctions only” action. It extends the default * Compare strategy. Onlymethods that are different from the default * CompareStrategy areimplemented in here. */ public class CompareStrategyFunctions extendsCompareStrategy { /** * Invoke the constructor of the default comparestrategy. */ public CompareStrategyFunctions(View view) { super(view); }/** * Return the name of the compare option implemented through this *strategy. */ public String compareOptionName() { return “Comparefunctions only”; } /** * Retrieve the text of an element in thedocument, which will be used * in the compare process. Onlyfunction-header elements are * returned; no other elements participatein the compare process. */ public String elementText(int element) { if(element >0) { // check that the parser has set the CLASS_FUNCTION //parser class for this element if ((view.elementClasses(element) &classFunction) != 0) { // if function header, return element's textreturn view.elementText(element); } } // not a function-header elementreturn null; } } elementTextNoComments(element)------------------------------ /** * Retrieve the text of a document'selement without the comments. * Overrides the generic call-back methoddefined in Common Parser. * @param element - element in the document */String elementTextNoComments(int element) { if (element >0) { returnelementCode(element); // see method below } else { return null; } }elementCode(element) -------------------- /** * Retrieve the code(comments stripped) of an element. * The comment characters, establishedas such by the parser, are * blanked out in the returned string. * * Forexample, for this line of C code: *  int i = 10 /* a reasonable constant*/ + j; // init.i * the parser will have set this style string: *Kkk_I_O_Nn_Ccccccccccccccccccccccccccc_O_IP_Cccccccccc * and this methodwill return the string below: *  int i = 10     +j; * An alternativeimplementation of this method could strip, rather * replace with blanks,the comment characters, returning: *  int i = 10 +j; * * @paramelement - element in the document */ String elementCode(int element) {// style characters used by the parser to mark comments StringcommentStyles = “Cc”; // retrieve this element's style string Stringstyle = view.elementStyle(element); // retrieve this element's textString Buffer code = new String Buffer(view.elementText(element)); //establish the valid range of the element text/style to process int i =style.length(); if (code.length() <i) { i = code.length(); } // blankout all comment characters in the element's text while (--i >= 0) { if(commentStyles.indexOf(style.charAt(i)) >= 0) { code.setCharAt(i, ‘ ’);} } // return resulting string return code.toString(); }

EXAMPLE

[0083] Referring to FIGS. 10 and 11, an example illustrating comparisonsof two C-language documents is shown. As illustrated in FIG. 10, thedifferences between the two documents 250 and 252 consist of one actualcode change at 254, and a series of documentation (comments) changes at256, 258 and 260. As illustrated in FIG. 11, when the menu option“Ignore comments” 132 is selected, the compare only highlights theactual code changes at 254, clearing in FIG. 11 the cluttered display ofFIG. 10 from all the compare information 256, 258, 260 which is notpertinent. The compare extension 168 in this case is implemented in theC parser 210, an embodiment of parser 166. C parser 210 strips thecomments (all text identified by the COMMENT class and comment stylecharacters in the total and incremental parse operations) when supplyingthe text to the compare utility 160. As a result, the line-by-linecomparison taking place after the hash operation will see these lines aseffectively identical.

[0084] The user may be optionally informed of further differencesexisting between the compared documents, beyond the ones highlighted,through various means, such as (1) a message on the status line; or (2)keeping all the differences present in the compare bars 262 locatedbetween the edit views 250, 252. This option can be implemented bycarrying out the compare procedure for the compare bars 262 between theviews using the default compare strategy (or the parser defaultstrategy, or a variation of it), and for the highlights 254 inside theviews using the compare extension's registered strategy. Or, (3) othersimilar means, depending on the particular implementation.

Advantages over the Prior Art

[0085] It is, therefore, an advantage of the invention that there isprovided a system and method for comparing source files code whileignoring the comments.

[0086] It is a further advantage of the invention that there is provideda system and method for comparing functions and/or methods defined insource files (names, arguments, etc.), regardless of their detailedimplementation.

[0087] It is a further advantage of the invention that there is provideda system and method for comparing code while ignoring the text locatedoutside margins, in a prefix area, and/or including or excludingsequence numbers, and so forth.

[0088] It is a further advantage of the invention that there is provideda system and method for comparing source code statement-by-statement,e.g., one-line statement vs. a reformatted statement spread over anumber of document lines, effectively ignoring the differences informatting styles between programmers or coding standards and practicesbetween projects or institutions.

[0089] It is a further advantage of the invention that there is provideda system and method for comparing constant definitions or keys in, forexample, Java resource files, where the values are different (e.g., newconstant values or NLS-translated values), in which case the user maystill be interested in an indication that the value changed, but doesnot want to have every line flagged as non-comparing.

[0090] It is a further advantage of the invention that there is provideda system and method for comparing documents with expected (controlled)differences, such as the change of a class name or a variable name.

[0091] It is a further advantage of the invention that there is provideda system and method facilitating language-sensitive application ofcompare options (e.g., ignore case and ignore blanks applied only tolanguage elements and comments, but not to contents of strings).

[0092] It is a further advantage of the invention that there is provideda system and method for comparing documents in any manner that isadvantageous for a specific type of filed handled by the edit system.

Alternative Embodiments

[0093] It will be appreciated that, although specific embodiments of theinvention have been described herein for purposes of illustration,various modifications may be made without departing from the spirit andscope of the invention. In particular, it is within the scope of theinvention to provide a computer program product or program element, or aprogram storage or memory device such as a solid or fluid transmissionmedium, magnetic or optical wire, tape or disc, or the like, for storingsignals readable by a machine, for controlling the operation of acomputer according to the method of the invention and/or to structureits components in accordance with the system of the invention.

[0094] Further, each step of the method may be executed on any generalcomputer, such as an IBM System 390, AS/400, PC or the like and pursuantto one or more, or a part of one or more, program elements, modules orobjects generated from any programming language, such as C++, Java, PI/1or the like. And still further, each said step, or a file or object orthe like implementing each said step, may be executed by special purposehardware or a circuit module designed for that purpose.

[0095] Accordingly, the scope of protection of this invention is limitedonly by the following claims and their equivalents.

The embodiments of the invention in which an exclusive property orprivilege is claimed are defined as follows:
 1. System for comparingsource files, comprising: a language specific parser; an edit systemincluding a comparator for comparing at least two files, said comparatorselectively querying said language specific parser for any compareextensions.
 2. The system of claim 1, said edit system furthercomprising: a set of compare methods defining a compare stategy forexecution by said comparator; said comparator being responsive to saidlanguage specific parser for selectively extending said compare strategyin accordance with said compare extensions.
 3. The system of claim 2,said edit system further comprising: a compare command enabled by anextension registration process for querying said language specificparser for said compare extensions.
 4. The system of claim 3, furthercomprising: a common parser including a register compare extensionsentry point responsive to a call from said comparator initiating saidextension registration process for registering a default strategy; andsaid language specific parser for extending said common parser byoverriding said register compare extension entry point with any compareextensions to be registered.
 5. The system of claim 3, said languagespecific parser further comprising a plurality of platform specificparsers for extending said language specific parser by registeringextensions for different platforms.
 6. The system of claim 2, furthercomprising a plurality of languages specific parsers.
 7. The system ofclaim 6, said comparator initiating said compare registration processwhen each of said files is associated with a same language specificparser.
 8. The system of claim 1, further comprising a display fordisplaying in a pull-down menu a plurality of compare utility actionsand compare options, said compare options comprising a compare strategyincluding said compare extensions.
 9. The system of claim 1, saidcompare extensions specifying that said comparator ignore comments. 10.The system of claim 1, said compare extensions specifying the comparisonof functions and methods defined in source files without regard to theirdetailed implementation.
 11. The system of claim 1, said compareextensions specifying the comparison of code while ignoring text locatedoutside of margins, in a prefix area, and/or including or excludingsequence numbers.
 12. The system of claim 1, said compare extensionsspecifying the comparison of source code statement by statement.
 13. Thesystem of claim 12, said comparison of source code statement bystatement effectively ignoring differences in formatting styles.
 14. Thesystem of claim 1, said compare extensions providing for the comparisonof constant key definitions and identification of a change in valuewithout flagging every line containing a given changed constant key asnon-comparing.
 15. The system of claim 1, said compare extensionsproviding for changed class or variable names as expected changes not tobe flagged as non-comparing.
 16. System for comparing document files,comprising: a language specific parser; an edit system including acomparator for comparing two files, said comparator selectively queryingsaid language specific parser for any compare extensions; a display fordisplaying in a pull-down menu a plurality of compare utility actionsand compare options, selected said compare options comprising a comparestrategy including said compare extensions; said language specificparser being responsive to user selection of a said compare extensionfor providing a corresponding method to said comparator; and saiddisplay further for displaying said document files with non-comparingelements highlighted according to said compare strategy.
 17. Method forcomparing entities, comprising: selecting a plurality of compareentities; identifying an attached parser corresponding to each saidcompare entity; responsive to each said compare entity being identifiedto the same attached parser, executing a compare extension registrationprocess; responsive to said compare extension registration process,defining a compare strategy for comparing said entities.
 18. The methodof claim 17, further comprising the step of: responsive to userselection of a compare action, displaying to said user a compare dialogfor selecting said plurality of compare entities.
 19. The method ofclaim 18, further comprising the step of: responsive to said compareextension registration process, displaying to said user a further dialogcomprising language specific compare options for user selection indefining said compare strategy.
 20. The method of claim 19, furthercomprising the steps of: responsive to said compare action, registeringa default strategy; and selectively extending or overriding said defaultstrategy with any compare extensions to be registered.
 21. The methodclaim 20, further comprising the step of: operating a language specificparser and one of a plurality of platform specific parsers to registersaid compare extensions.
 22. The method of claim 17, said comparestrategy specifying that comments be ignored.
 23. The method of claim17, said compare strategy specifying the comparison of functions andmethods defined in source files without regard to their detailedimplementation.
 24. The method of claim 17, said compare strategyspecifying the comparison of code while ignoring text located outside ofmargins, in a prefix area, and/or including or excluding sequencenumbers.
 25. The method of claim 17, said compare strategy specifyingthe comparison of source code statement by statement.
 26. The method ofclaim 17, said comparison of source code statement by statementeffectively ignoring differences in formatting styles.
 27. The method ofclaim 17, said compare strategy providing for the comparison of constantkey definitions and identification of a change in value without flaggingevery line containing a given changed constant key as non-comparing. 28.The method of claim 17, said compare strategy providing for changedclass or variable names as expected changes not to be flagged asnon-comparing.
 29. Method for comparing document files, comprising thesteps of: comparing within an edit system at least two document filesaccording to a compare strategy including compare extensions provided byan external language specific parser; and displaying said document fileswith non-comparing elements highlighted according to said comparestrategy.
 30. A program storage device readable by a machine, tangiblyembodying a program of instructions executable by a machine to performmethod steps for comparing document files, said method steps comprising:comparing within an edit system at least two document files according toa compare strategy including compare extensions provided by an externallanguage specific parser; and displaying said document files withnon-comparing elements highlighted according to said compare strategy.31. A program storage device readable by a machine, tangibly embodying aprogram of instructions executable by a machine to perform method stepsfor entities, said method steps comprising: selecting a plurality ofcompare entities; identifying an attached parser corresponding to eachsaid compare entity; responsive to each said compare entity beingidentified to the same attached parser, executing a compare extensionregistration process; responsive to said compare extension registrationprocess, defining a compare strategy for comparing said entities; andresponsive to user selection of a compare action, displaying to saiduser a compare dialog for selecting said plurality of compare entities.32. The program storage device of claim 31, said method steps furthercomprising: responsive to said compare extension registration process,displaying to said user a further dialog comprising language specificcompare options for user selection in defining said compare strategy;responsive to said compare action, registering a default strategy; andselectively extending or overriding said default strategy with anycompare extensions to be registered.
 33. The program storage device ofclaim 31, said compare strategy specifying that comments be ignored. 34.The program storage device of claim 31, said compare strategy specifyingthe comparison of functions and methods defined in source files withoutregard to their detailed implementation.
 35. The program storage deviceof claim 31, said compare strategy specifying the comparison of codewhile ignoring text located outside of margins, in a prefix area, and/orincluding or excluding sequence numbers.
 36. The program storage deviceof claim 31, said compare strategy specifying the comparison of sourcecode statement by statement.
 37. The program storage device of claim 31,said comparison of source code statement by statement effectivelyignoring differences in formatting styles.
 38. The program storagedevice of claim 31, said compare strategy providing for the comparisonof constant key definitions and identification of a change in valuewithout flagging every line containing a given changed constant key asnon-comparing.
 39. The program storage device of claim 31, said comparestrategy providing for changed class or variable names as expectedchanges not to be flagged as non-comparing.
 40. A computer programproduct or computer program element for executing the method steps of:comparing within an edit system at least two document files according toa compare strategy including compare extensions provided by an externallanguage specific parser; and displaying said document files withnon-comparing elements highlighted according to said compare strategy.41. The system of claim 1, said compare extensions providing forcomparing documents according to an attribute of the type of filehandled by said edit system.